//
//  BaseTabBarViewController.m
//  接口测试
//
//  Created by 叶子韬韬 on 2017/4/16.
//  Copyright © 2017年 叶子韬韬. All rights reserved.
//

#import "BaseTabBarViewController.h"
#import "HomeViewController.h"
#import "MyViewController.h"
#import "MainCacheTool.h"


@interface BaseTabBarViewController ()

@end

@implementation BaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initData];
}
-(void)initData{
    NSString *path = [[NSBundle mainBundle]pathForResource:@"MainVCSettings.json" ofType:nil];
    NSData *data = [NSData dataWithContentsOfFile:path];
    NSArray *arr = [MainCacheTool getArrayWithData:data];
    for (NSDictionary *dict in arr) {
        [self addChileViewController:dict[@"vcName"] WithImage:dict[@"imageName"] WithSlectImage:[NSString stringWithFormat:@"%@__highlighted",dict[@"imageName"]] WithTitle:dict[@"title"]];
    }
}

-(void)addChileViewController:(NSString *)VC WithImage:(NSString *)image WithSlectImage:(NSString *)selectImage WithTitle:(NSString *)title{
    
    UIViewController *childVC = [[NSClassFromString(VC) alloc]init];
    childVC.title = title;
    // 设置图片
    [childVC.tabBarItem setImage:[[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [childVC.tabBarItem setSelectedImage:[[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childVC];
    
    [self addChildViewController:nav];
    
    
}

@end
